-- 活动表 --
local Lang = require("common.Lang")
local Util = require("common.Util")
local Msg = require("core.Msg")
local ObjHuman = require("core.ObjHuman")
local Grid = require("bag.Grid")
local ActTimeTableExcel = require("excel.actTimeTable")

function CG_ACTTIMETABLE_QUERY(human)
	local msgRet = Msg.gc.GC_ACTTIMETABLE_QUERY
	local timeTableConfig = ActTimeTableExcel.timeTable
	local actConfig = ActTimeTableExcel.act
	msgRet.lists[0] = #timeTableConfig
	for i=1,#timeTableConfig do
		msgRet.lists[i].week = i
		msgRet.lists[i].acts[0] = #timeTableConfig[i].actGroup
		for j=1,#timeTableConfig[i].actGroup do
			local actID = timeTableConfig[i].actGroup[j]
			msgRet.lists[i].acts[j].id = actID
			msgRet.lists[i].acts[j].name = actConfig[actID].name
		end
	end
	--Msg.trace(msgRet)
	Msg.send(msgRet,human.fd)
end

function CG_ACTTIMETABLE_ACT(human,actID)
	local config = ActTimeTableExcel.act
	if not config[actID] then return end

	local msgRet = Msg.gc.GC_ACTTIMETABLE_ACT
	msgRet.id = actID
	msgRet.timeDesc = config[actID].timeDesc
	msgRet.actDesc = config[actID].actDesc
	
	msgRet.showReward[0] = #config[actID].showReward
	for i=1,#config[actID].showReward do
		local itemID = config[actID].showReward[i][1]
		local itemCnt = config[actID].showReward[i][2]
		Grid.makeItem(msgRet.showReward[i], itemID, itemCnt)
	end

	msgRet.panelID = config[actID].panelID

	--Msg.trace(msgRet)
	Msg.send(msgRet,human.fd)
end